﻿using BarManager.Core.Entity;
using System.Data.Entity.ModelConfiguration;

namespace BarManager.Infrastructure.Data.Mapping
{
    public class MesaMap : EntityTypeConfiguration<Mesa>
    {
        public MesaMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Nombre)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Mesas");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Nombre).HasColumnName("Nombre");
            this.Property(t => t.Libre).HasColumnName("Libre");
            this.Property(t => t.ZonaId).HasColumnName("ZonaId");
            
            // Relationships
            this.HasRequired(t => t.Zona)
                .WithMany(t => t.Mesas)
                .HasForeignKey(d => d.ZonaId);
        }
    }
}
